/*
 * One example for NOI CSP-J Lesson 8:
 * <https://courses.fmsoft.cn/plzs/noijunior-other-data-structures.html>
 *
 * Author: Vincent Wei
 *  - <https://github.com/VincentWei>
 *  - <https://gitee.com/vincentwei7>
 *
 * Copyright (C) 2025 FMSoft <https://www.fmsoft.cn>.
 * License: GPLv3
 */
#include <algorithm>
#include <string>
#include <iostream>

using namespace std;

int max_common_substring(const string& s1, const string& s2)
{
    size_t m = s1.length();
    size_t n = s2.length();

    // 对两个字符串所有的索引值 i 和 j，计算从这两个索引值开始
    // 的公共子串长度，并记录其最大值。
    size_t ans = 0;
    for (size_t i = 0; i < m; i++) {
        for (size_t j = 0; j < n; j++) {
            size_t curr = 0;
            while ((i + curr) < m && (j + curr) < n
                   && s1[i + curr] == s2[j + curr]) {
                curr++;
            }
            ans = max(ans, curr);
        }
    }

    return ans;
}

int main()
{
    string s1 = "One example";
    string s2 = "Two examples";
    cout << max_common_substring(s1, s2) << endl;
    return 0;
}
